<template>
  <div align="center">
    <dept-edit ref="deptEdit" v-on:save-finished="searchSetmeal"></dept-edit>
    <el-divider></el-divider>
      <img :src=Setmeal.img width="500px">
      <el-divider></el-divider>
      <el-row>
        <el-col :span="24"><div class="grid-content bg-purple">套餐名称：{{Setmeal.name}}</div></el-col>
        <el-col :span="24"><div class="grid-content bg-purple">{{Setmeal.remark}}</div></el-col>
        <el-col :span="24"><div class="grid-content bg-purple">适用人群：{{Setmeal.sex == "0" ? "不限" : Setmeal.sex == "1" ? "男" : "女"}}---{{Setmeal.age}}</div></el-col>
        <el-col :span="24"><div class="grid-content bg-purple"><h1 @click="notice">预约须知</h1></div></el-col>
        <el-col :span="24"><div class="grid-content bg-purple" @click="yy()" style="color:red">预约</div></el-col>
        <el-col :span="24"><div class="grid-content bg-purple">
          <el-table
            size="small"
            current-row-key="id"
            :data="dataList"
            stripe
            highlight-current-row>
            <el-table-column
              prop="name"
              label="项目名称"
              align="center"
            ></el-table-column>
            <el-table-column
              prop="remark"
              label="项目内容"
              align="center"
            ></el-table-column>
          </el-table>
        </div></el-col>    
      </el-row>
      <el-divider></el-divider>
  </div>
</template>

<script>
import DeptEdit from '@/components/nd/deptEdit'
import { getSetmealById } from "@/api/setmeal";
import { getCheckgroupById } from "@/api/checkgroup";

export default {
  data() {
    return {
      dataList: [],
      Setmeal:{},
    }
  },
  methods: {
    searchSetmeal(){
      listAllSetmeal()
        .then((response) => {
          console.log(response);
        })
        .catch((error) => {
          this.outputError(error);
        });
    },
    async yy(index) {
      console.log(index)
      this.$refs.deptEdit.$emit('openEditDeptDialog',this.Setmeal.id)
    },
    notice(){
      this.$router.push({
        path: '/notice',
      })
    },
    outputError(error) {
      console.log(error.response ? error.response : error.message);
      this.$message({
        showClose: true,
        message: "出错了，请按F12查看浏览器日志。",
        type: "error",
      });
    },
  },
  components: { DeptEdit },
  created() {
    var id = this.$route.query.data
    getSetmealById(id).then(response => {
        this.Setmeal=response.data
      })
      .catch(error => {
        this.outputError(error)        
      }) 
    getCheckgroupById(id)
      .then((response) => {
        console.log(response);
        this.dataList=response.data
      })
      .catch((error) => {
        this.outputError(error);
      });
  }
}
</script>

<style>

</style>